package ahblue.cn.tanzi.util;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.widget.ImageView;
import com.bumptech.glide.Glide;


public class ImageLoadUtil {

    public static void load(Context context, String path, ImageView imageView) {
        if (null != context)
            Glide.with(context).load(path).into(imageView);
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    public static void load(Activity context, String path, ImageView imageView) {
        if (!context.isDestroyed()) {
            Glide.with(context).load(path).into(imageView);
        }
    }


    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    public static void load(FragmentActivity context, String path, ImageView imageView) {
        if (!context.isDestroyed()) {
            Glide.with(context).load(path).into(imageView);
        }
    }

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    public static void load(Fragment context, String path, ImageView imageView) {
        if (context != null && context.getActivity() != null) {
            Glide.with(context).load(path).into(imageView);
        }
    }

}
